#include <iostream>
#include <deque>

using std::cout;
using std::endl;
using std::deque;

void test()
{
    //1、初始化
    /* deque<int> number;//1、创建无参对象 */
    /* deque<int> number(10, 3);//2、count个value */
    /* int arr[10] = {1, 2, 4, 6, 8, 9, 6, 5, 4, 19}; */
    //3、迭代器范围的形式
    /* deque<int> number(arr, arr + 10);//[arr, arr + 10) */
    //4、拷贝构造函数
    /* deque<int> number2(number); */
    //5、使用大括号的形式初始化
    deque<int> number = {1, 3, 5, 7, 9, 6, 4, 8, 2, 100};

    //2、遍历
    //2.1、使用下标
    for(size_t idx = 0; idx != number.size(); ++idx)
    {
        cout << number[idx] << "  ";
    }
    cout << endl;

    //2.2、未初始化的迭代器
    deque<int>::iterator it;
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    //2.3、初始化的迭代器
    deque<int>::iterator it2 = number.begin();
    /* for(deque<int>::iterator it2 = number.begin(); it2 != number.end(); ++it2) */
    for(it2 = number.begin(); it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //2.4、for与auto
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;

#if 0
    for(size_t idx = 0; idx != number2.size(); ++idx)
    {
        cout << number2[idx] << "  ";
    }
    cout << endl;
#endif

}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

